{% extends "dashboard/base.html" %}
{% load i18n %}
{% load prices_i18n %}
{% load status %}

{% block title %}
  {% trans "Shipping methods" context "Dashboard shipping methods list" %} - {{ block.super }}
{% endblock %}

{% block body_class %}body-shipping-methods{% endblock %}

{% block menu_delivery_class %}active{% endblock %}

{% block breadcrumbs %}
  <ul class="breadcrumbs">
    <li class="visible-s">
      {% trans "Shipping methods" context "Dashboard shipping methods list" %}
    </li>
  </ul>
{% endblock %}

{% block content %}
  <div class="row">
    <div class="col s12">
      <div class="card">
        <div class="data-table-header-action">
          <a href="{% url 'dashboard:shipping-method-add' %}" class="btn-data-table btn-flat" title="{% trans "Add method" context "Shipping method list add button text" %}">
            {% trans "Add" context "Dashboard add action" %}
          </a>
        </div>
        <div class="data-table-container">
          <table class="bordered highlight responsive data-table">
            {% if shipping_methods %}
              <thead>
                <tr>
                  <th>
                    {% trans "Name" context "Shipping methods table header" %}
                  </th>
                  <th>
                    {% trans "Price range" context "Shipping methods table header" %}
                  </th>
                  <th class="wide">
                    {% trans "Countries" context "Shipping methods table header" %}
                  </th>
                </tr>
              </thead>
              <tbody>
                {% for method in shipping_methods %}
                  <tr data-action-go="{% url 'dashboard:shipping-method-detail' pk=method.pk %}">
                    <td>
                      {{ method }}
                    </td>
                    <td>
                      {% if not method.price_range %}
                        -
                      {% elif method.price_range.min_price == method.price_range.max_price %}
                        {% gross method.price_range.min_price html=True %}
                      {% else %}
                        {% gross method.price_range.min_price html=True %}&ndash;{% gross method.price_range.max_price html=True %}
                      {% endif %}
                    </td>
                    <td>
                      {{ method.countries|join:", " }}
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            {% else %}
              <tbody>
                <tr>
                  <td>
                    <span>
                      {% trans "No Shipping methods found" context "Empty Shipping methods table message" %}
                    </span>
                  </td>
                </tr>
              </tbody>
            {% endif %}
          </table>
        </div>
      </div>
    </div>
  </div>
  {% include "dashboard/includes/_pagination.html" %}
{% endblock %}
